-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix: prevent duplicate LM Studio models with case-insensitive deduplication #7185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…cation - Keep both listDownloadedModels and listLoaded APIs to support JIT loading - Implement case-insensitive deduplication to prevent duplicates - When duplicates are found, prefer loaded model data for accurate runtime info - Add test coverage for deduplication logic - Addresses feedback about LM Studio's JIT Model Loading feature (v0.3.5+) Fixes #6954
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution! I've reviewed the changes and found some issues that need attention. While the approach to support JIT Model Loading is good, the deduplication logic has some critical flaws that could cause incorrect model matching.
| expect(result).toEqual({ [mockRawModel.modelKey]: expectedParsedModel }) | ||
| }) | ||
|
|
||
| it("should deduplicate models when both downloaded and loaded", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good test case! However, could we add more edge cases to ensure robustness? For example:
- Models with similar names ("llama-3" vs "llama-3.1")
- Multiple loaded models with various duplicate scenarios
- Case sensitivity edge cases
- Models with special characters in their paths/keys
- When a loaded model ID is found in any downloaded model key (case-insensitive) - Remove the downloaded model and replace with the loaded model - This ensures loaded models with runtime info take precedence - Updated tests to verify the correct deduplication behavior
- Enhanced deduplication to use path segment matching instead of simple substring - Prevents false positives like 'llama' matching 'codellama' - Added comprehensive test cases for edge cases and multiple scenarios - Maintains support for JIT Model Loading feature
|
Hey @mechanicmuthu, what do you think of this approach? |
|
Hey @daniel-lxs
Autoloading of an unloaded model is working and tested now by me. However, the duplicate issues is there. This is due to different namings here when the model is loaded.
The bottom 2 with simpler names are from currently loaded models, the top 2 are from all models. All 4 work correctly though. |
|
@daniel-lxs I think the solution requires more complex matching logic because LM Studio seems to adapt the model keys to make them unique if you have different quantizations of the same model downloaded. In that case the key isn't necessarily a substring of the path any more. Example: |
|
Then I think it would be great to create a properly scoped issue because lm-studio is making it quite hard for us to deduplicate the models. |
|
@daniel-lxs I'm sorry if I'm missing a point here but I don't think it needs to be that hard. In my opinion, the initial PR (#6956) provided a simple working solution that consistently used the model's path to prevent duplicate entries and replaced the downloaded model with more details if a loaded model with the same path was found. |

Summary
This PR fixes the issue where LM Studio models appeared twice in the Provider Configuration Profile when they were both downloaded and loaded. This implementation addresses the feedback from @mechanicmuthu about LM Studio's JIT Model Loading feature.
Problem
The previous implementation fetched models from two different LM Studio APIs:
listDownloadedModels()- showed all models on disklistLoaded()- showed models currently in memoryThis caused duplicates when a model was both downloaded and loaded, with inconsistent keys (
model.pathvsmodel.modelKey).Solution
This PR implements a case-insensitive deduplication approach that:
Benefits
Testing
Context
This replaces PR #7141 which only showed loaded models and didn't align with LM Studio's JIT loading capabilities.
Fixes #6954
Important
Implements case-insensitive deduplication in
getLMStudioModels()to prevent duplicate model entries, preferring loaded models for accurate runtime data.getLMStudioModels()inlmstudio.tsto prevent duplicate model entries.lmstudio.test.tsfor deduplication logic, including path-based matching and distinct name handling.This description was created by
for 6aba8e5. You can customize this summary. It will automatically update as commits are pushed.